How To Test with QEMU for ARM

Intro


In this How To we are going to build a Linux kernel that will be used with QEMU and built with our GCC 4.3.3 cross-compiler. We then can use this to test, let's say, a custom Linux minimal file system. This is really basic and limited (I'm sure there are better ways to do this). The max memory your allowed to specify with QEMU is 256 MB, I believe. Nevertheless, this is a quick and dirty way to test. You willl need to get QEMU from your distro's repos. There may be many out there that will find this How To useless :P

Tar Balls


Here is a list of source packages that we'll need for the build. You can either download them now or wait 'til later in the How To.
  • linux-2.6.38.tar.bz2

Create a Workspace


I recommend creating a workspace under your /home/<your user>/ directory that is dedicated to this build. So let's fire up your terminal and run the following:
export TESTING=~/workbench/testing
mkdir -pv $TESTING
cd $TESTING

Gather the Sources


Now that we have a workspace created and we are currently in the testing directory we can begin bringing down the sources and extracting them.

kernel

wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.38.tar.bz2
tar -pxjf linux-2.6.38.tar.bz2

Build Environment


To make things a little smoother let's setup some environment variables:
export INSTALLDIR=~/workbench/gcc-4.3.3/arm
export PATH=$INSTALLDIR/bin:$PATH
export CROSS=arm-none-linux-gnueabi
export CC=${CROSS}-gcc
export LD=${CROSS}-ld
export AS=${CROSS}-as
NOTE: Depending on whether you are using a cross-compiler built from my other wikis you might need to change INSTALLDIR to point to your cross-compiler.

Build


cd linux-2.6.38/
make mrproper
make ARCH=arm versatile_defconfig
make ARCH=arm menuconfig
 
enable EABI, save and exit
 
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- uImage
boot kernel and your root file system:
qemu-system-arm -M versatilepb -m 128M -kernel /home/<your user>/workbench/testing/linux-2.6.38/arch/arm/boot/zImage -initrd <path to your>/rootfs.img.gz -append "root=/dev/ram rdinit=/bin/<shell or linuxrc>"
If all goes well, you should be able to hit the enter key and the familiar # should appear. Like I said earlier, this might not be very helpful to anyone. I use time to time, but mainly just to make sure a custom Linux file system works.